
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;


using DotNetNuke.Framework.Providers;


namespace DNNspot.PropertyAgentImport
{
	/// <summary>
	/// Encapsulates the 'Ventrian_PropertyAgent_Property' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(Property))]	
	[XmlType("Property")]
	public partial class Property : esProperty
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new Property();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Int32 propertyID)
		{
			var obj = new Property();
			obj.PropertyID = propertyID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Int32 propertyID, esSqlAccessType sqlAccessType)
		{
			var obj = new Property();
			obj.PropertyID = propertyID;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("PropertyCollection")]
	public partial class PropertyCollection : esPropertyCollection, IEnumerable<Property>
	{
		public Property FindByPrimaryKey(System.Int32 propertyID)
		{
			return this.SingleOrDefault(e => e.PropertyID == propertyID);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(Property))]
		public class PropertyCollectionWCFPacket : esCollectionWCFPacket<PropertyCollection>
		{
			public static implicit operator PropertyCollection(PropertyCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator PropertyCollectionWCFPacket(PropertyCollection collection)
			{
				return new PropertyCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class PropertyQuery : esPropertyQuery
	{
		public PropertyQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "PropertyQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(PropertyQuery query)
		{
			return PropertyQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator PropertyQuery(string query)
		{
			return (PropertyQuery)PropertyQuery.SerializeHelper.FromXml(query, typeof(PropertyQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esProperty : esEntity
	{
		public esProperty()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Int32 propertyID)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(propertyID);
			else
				return LoadByPrimaryKeyStoredProcedure(propertyID);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Int32 propertyID)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(propertyID);
			else
				return LoadByPrimaryKeyStoredProcedure(propertyID);
		}

		private bool LoadByPrimaryKeyDynamic(System.Int32 propertyID)
		{
			PropertyQuery query = new PropertyQuery();
			query.Where(query.PropertyID == propertyID);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Int32 propertyID)
		{
			esParameters parms = new esParameters();
			parms.Add("PropertyID", propertyID);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.PropertyID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? PropertyID
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.PropertyID);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.PropertyID, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.PropertyID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.ModuleID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? ModuleID
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.ModuleID);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.ModuleID, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.ModuleID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.PropertyTypeID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? PropertyTypeID
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.PropertyTypeID);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.PropertyTypeID, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.PropertyTypeID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.IsFeatured
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Boolean? IsFeatured
		{
			get
			{
				return base.GetSystemBoolean(PropertyMetadata.ColumnNames.IsFeatured);
			}
			
			set
			{
				if(base.SetSystemBoolean(PropertyMetadata.ColumnNames.IsFeatured, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.IsFeatured);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.DateCreated
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? DateCreated
		{
			get
			{
				return base.GetSystemDateTime(PropertyMetadata.ColumnNames.DateCreated);
			}
			
			set
			{
				if(base.SetSystemDateTime(PropertyMetadata.ColumnNames.DateCreated, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.DateCreated);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.DateModified
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? DateModified
		{
			get
			{
				return base.GetSystemDateTime(PropertyMetadata.ColumnNames.DateModified);
			}
			
			set
			{
				if(base.SetSystemDateTime(PropertyMetadata.ColumnNames.DateModified, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.DateModified);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.DatePublished
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? DatePublished
		{
			get
			{
				return base.GetSystemDateTime(PropertyMetadata.ColumnNames.DatePublished);
			}
			
			set
			{
				if(base.SetSystemDateTime(PropertyMetadata.ColumnNames.DatePublished, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.DatePublished);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.DateExpired
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? DateExpired
		{
			get
			{
				return base.GetSystemDateTime(PropertyMetadata.ColumnNames.DateExpired);
			}
			
			set
			{
				if(base.SetSystemDateTime(PropertyMetadata.ColumnNames.DateExpired, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.DateExpired);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.ViewCount
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? ViewCount
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.ViewCount);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.ViewCount, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.ViewCount);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.Status
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? Status
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.Status);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.Status, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.Status);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.AuthorID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? AuthorID
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.AuthorID);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.AuthorID, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.AuthorID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.Rating
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? Rating
		{
			get
			{
				return base.GetSystemDecimal(PropertyMetadata.ColumnNames.Rating);
			}
			
			set
			{
				if(base.SetSystemDecimal(PropertyMetadata.ColumnNames.Rating, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.Rating);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.RatingCount
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? RatingCount
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.RatingCount);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.RatingCount, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.RatingCount);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.CommentCount
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? CommentCount
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.CommentCount);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.CommentCount, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.CommentCount);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.ModifiedID
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Int32? ModifiedID
		{
			get
			{
				return base.GetSystemInt32(PropertyMetadata.ColumnNames.ModifiedID);
			}
			
			set
			{
				if(base.SetSystemInt32(PropertyMetadata.ColumnNames.ModifiedID, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.ModifiedID);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.Latitude
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? Latitude
		{
			get
			{
				return base.GetSystemDecimal(PropertyMetadata.ColumnNames.Latitude);
			}
			
			set
			{
				if(base.SetSystemDecimal(PropertyMetadata.ColumnNames.Latitude, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.Latitude);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Ventrian_PropertyAgent_Property.Longitude
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? Longitude
		{
			get
			{
				return base.GetSystemDecimal(PropertyMetadata.ColumnNames.Longitude);
			}
			
			set
			{
				if(base.SetSystemDecimal(PropertyMetadata.ColumnNames.Longitude, value))
				{
					OnPropertyChanged(PropertyMetadata.PropertyNames.Longitude);
				}
			}
		}		
		
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "PropertyID": this.str().PropertyID = (string)value; break;							
						case "ModuleID": this.str().ModuleID = (string)value; break;							
						case "PropertyTypeID": this.str().PropertyTypeID = (string)value; break;							
						case "IsFeatured": this.str().IsFeatured = (string)value; break;							
						case "DateCreated": this.str().DateCreated = (string)value; break;							
						case "DateModified": this.str().DateModified = (string)value; break;							
						case "DatePublished": this.str().DatePublished = (string)value; break;							
						case "DateExpired": this.str().DateExpired = (string)value; break;							
						case "ViewCount": this.str().ViewCount = (string)value; break;							
						case "Status": this.str().Status = (string)value; break;							
						case "AuthorID": this.str().AuthorID = (string)value; break;							
						case "Rating": this.str().Rating = (string)value; break;							
						case "RatingCount": this.str().RatingCount = (string)value; break;							
						case "CommentCount": this.str().CommentCount = (string)value; break;							
						case "ModifiedID": this.str().ModifiedID = (string)value; break;							
						case "Latitude": this.str().Latitude = (string)value; break;							
						case "Longitude": this.str().Longitude = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "PropertyID":
						
							if (value == null || value is System.Int32)
								this.PropertyID = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.PropertyID);
							break;
						
						case "ModuleID":
						
							if (value == null || value is System.Int32)
								this.ModuleID = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.ModuleID);
							break;
						
						case "PropertyTypeID":
						
							if (value == null || value is System.Int32)
								this.PropertyTypeID = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.PropertyTypeID);
							break;
						
						case "IsFeatured":
						
							if (value == null || value is System.Boolean)
								this.IsFeatured = (System.Boolean?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.IsFeatured);
							break;
						
						case "DateCreated":
						
							if (value == null || value is System.DateTime)
								this.DateCreated = (System.DateTime?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.DateCreated);
							break;
						
						case "DateModified":
						
							if (value == null || value is System.DateTime)
								this.DateModified = (System.DateTime?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.DateModified);
							break;
						
						case "DatePublished":
						
							if (value == null || value is System.DateTime)
								this.DatePublished = (System.DateTime?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.DatePublished);
							break;
						
						case "DateExpired":
						
							if (value == null || value is System.DateTime)
								this.DateExpired = (System.DateTime?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.DateExpired);
							break;
						
						case "ViewCount":
						
							if (value == null || value is System.Int32)
								this.ViewCount = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.ViewCount);
							break;
						
						case "Status":
						
							if (value == null || value is System.Int32)
								this.Status = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.Status);
							break;
						
						case "AuthorID":
						
							if (value == null || value is System.Int32)
								this.AuthorID = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.AuthorID);
							break;
						
						case "Rating":
						
							if (value == null || value is System.Decimal)
								this.Rating = (System.Decimal?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.Rating);
							break;
						
						case "RatingCount":
						
							if (value == null || value is System.Int32)
								this.RatingCount = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.RatingCount);
							break;
						
						case "CommentCount":
						
							if (value == null || value is System.Int32)
								this.CommentCount = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.CommentCount);
							break;
						
						case "ModifiedID":
						
							if (value == null || value is System.Int32)
								this.ModifiedID = (System.Int32?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.ModifiedID);
							break;
						
						case "Latitude":
						
							if (value == null || value is System.Decimal)
								this.Latitude = (System.Decimal?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.Latitude);
							break;
						
						case "Longitude":
						
							if (value == null || value is System.Decimal)
								this.Longitude = (System.Decimal?)value;
								OnPropertyChanged(PropertyMetadata.PropertyNames.Longitude);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esProperty entity)
			{
				this.entity = entity;
			}
			
	
			public System.String PropertyID
			{
				get
				{
					System.Int32? data = entity.PropertyID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.PropertyID = null;
					else entity.PropertyID = Convert.ToInt32(value);
				}
			}
				
			public System.String ModuleID
			{
				get
				{
					System.Int32? data = entity.ModuleID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ModuleID = null;
					else entity.ModuleID = Convert.ToInt32(value);
				}
			}
				
			public System.String PropertyTypeID
			{
				get
				{
					System.Int32? data = entity.PropertyTypeID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.PropertyTypeID = null;
					else entity.PropertyTypeID = Convert.ToInt32(value);
				}
			}
				
			public System.String IsFeatured
			{
				get
				{
					System.Boolean? data = entity.IsFeatured;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.IsFeatured = null;
					else entity.IsFeatured = Convert.ToBoolean(value);
				}
			}
				
			public System.String DateCreated
			{
				get
				{
					System.DateTime? data = entity.DateCreated;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DateCreated = null;
					else entity.DateCreated = Convert.ToDateTime(value);
				}
			}
				
			public System.String DateModified
			{
				get
				{
					System.DateTime? data = entity.DateModified;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DateModified = null;
					else entity.DateModified = Convert.ToDateTime(value);
				}
			}
				
			public System.String DatePublished
			{
				get
				{
					System.DateTime? data = entity.DatePublished;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DatePublished = null;
					else entity.DatePublished = Convert.ToDateTime(value);
				}
			}
				
			public System.String DateExpired
			{
				get
				{
					System.DateTime? data = entity.DateExpired;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.DateExpired = null;
					else entity.DateExpired = Convert.ToDateTime(value);
				}
			}
				
			public System.String ViewCount
			{
				get
				{
					System.Int32? data = entity.ViewCount;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ViewCount = null;
					else entity.ViewCount = Convert.ToInt32(value);
				}
			}
				
			public System.String Status
			{
				get
				{
					System.Int32? data = entity.Status;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Status = null;
					else entity.Status = Convert.ToInt32(value);
				}
			}
				
			public System.String AuthorID
			{
				get
				{
					System.Int32? data = entity.AuthorID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.AuthorID = null;
					else entity.AuthorID = Convert.ToInt32(value);
				}
			}
				
			public System.String Rating
			{
				get
				{
					System.Decimal? data = entity.Rating;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Rating = null;
					else entity.Rating = Convert.ToDecimal(value);
				}
			}
				
			public System.String RatingCount
			{
				get
				{
					System.Int32? data = entity.RatingCount;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.RatingCount = null;
					else entity.RatingCount = Convert.ToInt32(value);
				}
			}
				
			public System.String CommentCount
			{
				get
				{
					System.Int32? data = entity.CommentCount;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CommentCount = null;
					else entity.CommentCount = Convert.ToInt32(value);
				}
			}
				
			public System.String ModifiedID
			{
				get
				{
					System.Int32? data = entity.ModifiedID;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ModifiedID = null;
					else entity.ModifiedID = Convert.ToInt32(value);
				}
			}
				
			public System.String Latitude
			{
				get
				{
					System.Decimal? data = entity.Latitude;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Latitude = null;
					else entity.Latitude = Convert.ToDecimal(value);
				}
			}
				
			public System.String Longitude
			{
				get
				{
					System.Decimal? data = entity.Longitude;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.Longitude = null;
					else entity.Longitude = Convert.ToDecimal(value);
				}
			}
			

			private esProperty entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return PropertyMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public PropertyQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new PropertyQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(PropertyQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(PropertyQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private PropertyQuery query;		
	}



	[Serializable]
	abstract public partial class esPropertyCollection : esEntityCollection<Property>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return PropertyMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "PropertyCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public PropertyQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new PropertyQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(PropertyQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new PropertyQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(PropertyQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((PropertyQuery)query);
		}

		#endregion
		
		private PropertyQuery query;
	}



	[Serializable]
	abstract public partial class esPropertyQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return PropertyMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "PropertyID": return this.PropertyID;
				case "ModuleID": return this.ModuleID;
				case "PropertyTypeID": return this.PropertyTypeID;
				case "IsFeatured": return this.IsFeatured;
				case "DateCreated": return this.DateCreated;
				case "DateModified": return this.DateModified;
				case "DatePublished": return this.DatePublished;
				case "DateExpired": return this.DateExpired;
				case "ViewCount": return this.ViewCount;
				case "Status": return this.Status;
				case "AuthorID": return this.AuthorID;
				case "Rating": return this.Rating;
				case "RatingCount": return this.RatingCount;
				case "CommentCount": return this.CommentCount;
				case "ModifiedID": return this.ModifiedID;
				case "Latitude": return this.Latitude;
				case "Longitude": return this.Longitude;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem PropertyID
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.PropertyID, esSystemType.Int32); }
		} 
		
		public esQueryItem ModuleID
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.ModuleID, esSystemType.Int32); }
		} 
		
		public esQueryItem PropertyTypeID
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.PropertyTypeID, esSystemType.Int32); }
		} 
		
		public esQueryItem IsFeatured
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.IsFeatured, esSystemType.Boolean); }
		} 
		
		public esQueryItem DateCreated
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.DateCreated, esSystemType.DateTime); }
		} 
		
		public esQueryItem DateModified
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.DateModified, esSystemType.DateTime); }
		} 
		
		public esQueryItem DatePublished
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.DatePublished, esSystemType.DateTime); }
		} 
		
		public esQueryItem DateExpired
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.DateExpired, esSystemType.DateTime); }
		} 
		
		public esQueryItem ViewCount
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.ViewCount, esSystemType.Int32); }
		} 
		
		public esQueryItem Status
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.Status, esSystemType.Int32); }
		} 
		
		public esQueryItem AuthorID
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.AuthorID, esSystemType.Int32); }
		} 
		
		public esQueryItem Rating
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.Rating, esSystemType.Decimal); }
		} 
		
		public esQueryItem RatingCount
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.RatingCount, esSystemType.Int32); }
		} 
		
		public esQueryItem CommentCount
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.CommentCount, esSystemType.Int32); }
		} 
		
		public esQueryItem ModifiedID
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.ModifiedID, esSystemType.Int32); }
		} 
		
		public esQueryItem Latitude
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.Latitude, esSystemType.Decimal); }
		} 
		
		public esQueryItem Longitude
		{
			get { return new esQueryItem(this, PropertyMetadata.ColumnNames.Longitude, esSystemType.Decimal); }
		} 
		
		#endregion
		
	}


	
	public partial class Property : esProperty
	{

		#region PropertyValueCollectionByPropertyID - Zero To Many
		
		static public esPrefetchMap Prefetch_PropertyValueCollectionByPropertyID
		{
			get
			{
				esPrefetchMap map = new esPrefetchMap();
				map.PrefetchDelegate = DNNspot.PropertyAgentImport.Property.PropertyValueCollectionByPropertyID_Delegate;
				map.PropertyName = "PropertyValueCollectionByPropertyID";
				map.MyColumnName = "PropertyID";
				map.ParentColumnName = "PropertyID";
				map.IsMultiPartKey = false;
				return map;
			}
		}		
		
		static private void PropertyValueCollectionByPropertyID_Delegate(esPrefetchParameters data)
		{
			PropertyQuery parent = new PropertyQuery(data.NextAlias());

			PropertyValueQuery me = data.You != null ? data.You as PropertyValueQuery : new PropertyValueQuery(data.NextAlias());

			if (data.Root == null)
			{
				data.Root = me;
			}
			
			data.Root.InnerJoin(parent).On(parent.PropertyID == me.PropertyID);

			data.You = parent;
		}			
		
		/// <summary>
		/// Zero to Many
		/// Foreign Key Name - FK_Ventrian_EstateAgent_PropertyValue_Ventrian_EstateAgent_Property
		/// </summary>

		[XmlIgnore]
		public PropertyValueCollection PropertyValueCollectionByPropertyID
		{
			get
			{
				if(this._PropertyValueCollectionByPropertyID == null)
				{
					this._PropertyValueCollectionByPropertyID = new PropertyValueCollection();
					this._PropertyValueCollectionByPropertyID.es.Connection.Name = this.es.Connection.Name;
					this.SetPostSave("PropertyValueCollectionByPropertyID", this._PropertyValueCollectionByPropertyID);
				
					if (this.PropertyID != null)
					{
						if (!this.es.IsLazyLoadDisabled)
						{
							this._PropertyValueCollectionByPropertyID.Query.Where(this._PropertyValueCollectionByPropertyID.Query.PropertyID == this.PropertyID);
							this._PropertyValueCollectionByPropertyID.Query.Load();
						}

						// Auto-hookup Foreign Keys
						this._PropertyValueCollectionByPropertyID.fks.Add(PropertyValueMetadata.ColumnNames.PropertyID, this.PropertyID);
					}
				}

				return this._PropertyValueCollectionByPropertyID;
			}
			
			set 
			{ 
				if (value != null) throw new Exception("'value' Must be null"); 
			 
				if (this._PropertyValueCollectionByPropertyID != null) 
				{ 
					this.RemovePostSave("PropertyValueCollectionByPropertyID"); 
					this._PropertyValueCollectionByPropertyID = null;
					
				} 
			} 			
		}
			
		
		private PropertyValueCollection _PropertyValueCollectionByPropertyID;
		#endregion

		
		protected override esEntityCollectionBase CreateCollectionForPrefetch(string name)
		{
			esEntityCollectionBase coll = null;

			switch (name)
			{
				case "PropertyValueCollectionByPropertyID":
					coll = this.PropertyValueCollectionByPropertyID;
					break;	
			}

			return coll;
		}		
		/// <summary>
		/// Used internally by the entity's hierarchical properties.
		/// </summary>
		protected override List<esPropertyDescriptor> GetHierarchicalProperties()
		{
			List<esPropertyDescriptor> props = new List<esPropertyDescriptor>();
			
			props.Add(new esPropertyDescriptor(this, "PropertyValueCollectionByPropertyID", typeof(PropertyValueCollection), new PropertyValue()));
		
			return props;
		}
		
		/// <summary>
		/// Called by ApplyPostSaveKeys 
		/// </summary>
		/// <param name="coll">The collection to enumerate over</param>
		/// <param name="key">"The column name</param>
		/// <param name="value">The column value</param>
		private void Apply(esEntityCollectionBase coll, string key, object value)
		{
			foreach (esEntity obj in coll)
			{
				if (obj.es.IsAdded)
				{
					obj.SetProperty(key, value);
				}
			}
		}
		
		/// <summary>
		/// Used internally for retrieving AutoIncrementing keys
		/// during hierarchical PostSave.
		/// </summary>
		protected override void ApplyPostSaveKeys()
		{
			if(this._PropertyValueCollectionByPropertyID != null)
			{
				Apply(this._PropertyValueCollectionByPropertyID, "PropertyID", this.PropertyID);
			}
		}
		
	}
	



	[Serializable]
	public partial class PropertyMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected PropertyMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(PropertyMetadata.ColumnNames.PropertyID, 0, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.PropertyID;
			c.IsInPrimaryKey = true;
			c.IsAutoIncrement = true;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.ModuleID, 1, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.ModuleID;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.PropertyTypeID, 2, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.PropertyTypeID;
			c.NumericPrecision = 10;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.IsFeatured, 3, typeof(System.Boolean), esSystemType.Boolean);
			c.PropertyName = PropertyMetadata.PropertyNames.IsFeatured;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.DateCreated, 4, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = PropertyMetadata.PropertyNames.DateCreated;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.DateModified, 5, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = PropertyMetadata.PropertyNames.DateModified;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.DatePublished, 6, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = PropertyMetadata.PropertyNames.DatePublished;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.DateExpired, 7, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = PropertyMetadata.PropertyNames.DateExpired;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.ViewCount, 8, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.ViewCount;
			c.NumericPrecision = 10;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.Status, 9, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.Status;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.AuthorID, 10, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.AuthorID;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.Rating, 11, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = PropertyMetadata.PropertyNames.Rating;
			c.NumericPrecision = 18;
			c.NumericScale = 1;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.RatingCount, 12, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.RatingCount;
			c.NumericPrecision = 10;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.CommentCount, 13, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.CommentCount;
			c.NumericPrecision = 10;
			c.HasDefault = true;
			c.Default = @"((0))";
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.ModifiedID, 14, typeof(System.Int32), esSystemType.Int32);
			c.PropertyName = PropertyMetadata.PropertyNames.ModifiedID;
			c.NumericPrecision = 10;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.Latitude, 15, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = PropertyMetadata.PropertyNames.Latitude;
			c.NumericPrecision = 10;
			c.NumericScale = 5;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(PropertyMetadata.ColumnNames.Longitude, 16, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = PropertyMetadata.PropertyNames.Longitude;
			c.NumericPrecision = 10;
			c.NumericScale = 5;
			c.IsNullable = true;
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public PropertyMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string PropertyID = "PropertyID";
			 public const string ModuleID = "ModuleID";
			 public const string PropertyTypeID = "PropertyTypeID";
			 public const string IsFeatured = "IsFeatured";
			 public const string DateCreated = "DateCreated";
			 public const string DateModified = "DateModified";
			 public const string DatePublished = "DatePublished";
			 public const string DateExpired = "DateExpired";
			 public const string ViewCount = "ViewCount";
			 public const string Status = "Status";
			 public const string AuthorID = "AuthorID";
			 public const string Rating = "Rating";
			 public const string RatingCount = "RatingCount";
			 public const string CommentCount = "CommentCount";
			 public const string ModifiedID = "ModifiedID";
			 public const string Latitude = "Latitude";
			 public const string Longitude = "Longitude";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string PropertyID = "PropertyID";
			 public const string ModuleID = "ModuleID";
			 public const string PropertyTypeID = "PropertyTypeID";
			 public const string IsFeatured = "IsFeatured";
			 public const string DateCreated = "DateCreated";
			 public const string DateModified = "DateModified";
			 public const string DatePublished = "DatePublished";
			 public const string DateExpired = "DateExpired";
			 public const string ViewCount = "ViewCount";
			 public const string Status = "Status";
			 public const string AuthorID = "AuthorID";
			 public const string Rating = "Rating";
			 public const string RatingCount = "RatingCount";
			 public const string CommentCount = "CommentCount";
			 public const string ModifiedID = "ModifiedID";
			 public const string Latitude = "Latitude";
			 public const string Longitude = "Longitude";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(PropertyMetadata))
			{
				if(PropertyMetadata.mapDelegates == null)
				{
					PropertyMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (PropertyMetadata.meta == null)
				{
					PropertyMetadata.meta = new PropertyMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("PropertyID", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("ModuleID", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("PropertyTypeID", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("IsFeatured", new esTypeMap("bit", "System.Boolean"));
				meta.AddTypeMap("DateCreated", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("DateModified", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("DatePublished", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("DateExpired", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("ViewCount", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("Status", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("AuthorID", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("Rating", new esTypeMap("decimal", "System.Decimal"));
				meta.AddTypeMap("RatingCount", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("CommentCount", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("ModifiedID", new esTypeMap("int", "System.Int32"));
				meta.AddTypeMap("Latitude", new esTypeMap("decimal", "System.Decimal"));
				meta.AddTypeMap("Longitude", new esTypeMap("decimal", "System.Decimal"));			
				
				
				
				ProviderConfiguration providerConfiguration = ProviderConfiguration.GetProviderConfiguration("data");
				Provider provider = (Provider)providerConfiguration.Providers[providerConfiguration.DefaultProvider];

				string objectQualifier = provider.Attributes["objectQualifier"];

				if ((objectQualifier != string.Empty) && (objectQualifier.EndsWith("_") == false))
				{
					objectQualifier += "_";
				}

				if (objectQualifier != string.Empty)
				{
					meta.Source = objectQualifier + "Ventrian_PropertyAgent_Property";
					meta.Destination = objectQualifier + "Ventrian_PropertyAgent_Property";
					
					meta.spInsert = objectQualifier + "proc_Ventrian_PropertyAgent_PropertyInsert";				
					meta.spUpdate = objectQualifier + "proc_Ventrian_PropertyAgent_PropertyUpdate";		
					meta.spDelete = objectQualifier + "proc_Ventrian_PropertyAgent_PropertyDelete";
					meta.spLoadAll = objectQualifier + "proc_Ventrian_PropertyAgent_PropertyLoadAll";
					meta.spLoadByPrimaryKey = objectQualifier + "proc_Ventrian_PropertyAgent_PropertyLoadByPrimaryKey";
				}
				else
				{
					meta.Source = "Ventrian_PropertyAgent_Property";
					meta.Destination = "Ventrian_PropertyAgent_Property";
									
					meta.spInsert = "proc_Ventrian_PropertyAgent_PropertyInsert";				
					meta.spUpdate = "proc_Ventrian_PropertyAgent_PropertyUpdate";		
					meta.spDelete = "proc_Ventrian_PropertyAgent_PropertyDelete";
					meta.spLoadAll = "proc_Ventrian_PropertyAgent_PropertyLoadAll";
					meta.spLoadByPrimaryKey = "proc_Ventrian_PropertyAgent_PropertyLoadByPrimaryKey";
				}
				
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private PropertyMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
